package devaluator.functionality;
import java.io.*;
import java.io.File;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.ArrayList;
import java.util.Arrays;

//Recursively find all files in a dir and its all subdirs
//and return an array of files.
public class GetAllFiles {
	public static ArrayList<File> getAllFiles(File aFile,ArrayList<File> fileList){
		ArrayList<File> tFiles = null;
		if (aFile.isFile()){
			fileList.add(aFile);
			return fileList;
		}else if (aFile.isDirectory()){
			tFiles = new ArrayList<File>(Arrays.asList(aFile.listFiles()));
			if (tFiles != null){
				for (int i=0; i < tFiles.size(); i++)
					fileList = getAllFiles(tFiles.get(i),fileList);
			}
		}
		return fileList;
	}
}
